<template>
	<view>
		<!-- <u-navbar @click=""></u-navbar> -->
		<view class="public-nav">
			<view class="public-nav-fixed">
				<view class="public-nav-top" style="background-color: #FFF;color: #333;">
					<view class="public-nav-top-status-bar" :style="{ height: systemInfo.statusBarHeight + 'px' }">
					</view>
					<view class="public-nav-top-navbar-inner" :style="{ height: navHeight + 'px', lineHeight:navHeight+'px' }">
						<text class="iconfont iconarrow_left-copy" @click="returnclick"></text>
						<view>注册</view>
					</view>
				</view>
			</view>
			<view class="public-nav-placeholder" :style="{ height: Number(navHeight)+ Number(systemInfo.statusBarHeight) + 'px' }">
			</view>
		</view>
		<!-- 提示 -->
		<view class="box">
			<view class="box-title">
				你好,
			</view>
			<view class="box-title-center">
				欢迎注册!
			</view>
		</view>
		<!-- 登录 -->
		<view class="box-abilty">
			<!-- 输入框 -->
			<view class="textbox">
				<u-form :model="form" ref="uForm">
					<u-form-item left-icon="account-fill" :rightIconStyle="{color: '#888', fontSize: '32rpx'}">
						<u-input v-model="form.name" placeholder="请输入用户名" /></u-form-item>
				</u-form>
				<!-- 提交按钮 -->
				<u-button class="box-submit" type="primary" @click="submitLogin">提交</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				form:{
					name:'',
					
				},
				token:'',
				iphone:'',
				yqm:'',
				systemInfo:uni.getSystemInfoSync(),
				navHeight:'' ,
				optionHeight:38,
			}
		},
		onLoad(option) {
			this.token=option.token
			this.iphone=option.iphone
			this.yqm=option.yqm
			this.systemInfo=uni.getSystemInfoSync()
			this.navHeight=this.systemInfo.platform == 'ios' ? 44 : 48;
		},
		methods:{
			returnclick(){
				uni.reLaunch({
					url:'../APPlogin/index'
				})
			},
			submitLogin(){
				if(this.form.name.trim()==''){
					uni.showToast({
						title: '请输入客户名称',
						duration: 5000,  
						icon: 'none',
					});
					return 
				}
				uni.showLoading({
				    title: '登录中...',
					mask:true
				});
				uni.request({
					url: this.baseUrl + '/system/Login', 
					method: 'POST',
					dataType: 'json',
					data: {
						PERTB005CA03: this.iphone,
						ORMTB400CA03:this.erpID,
						ORMTB410CA00:this.form.name,
						PERTB007CA00:this.yqm,
						PERTB006CA00:'',
						token:this.token,
					},
					success: (res) => {
						console.log(res);
						uni.hideLoading();
						if (res.data.code == 200) {
							var str=JSON.stringify(res.data.data)
							uni.setStorageSync('userinfo', str);
							// uni.switchTab({
							// 	url: '../tabbar/home/index'
							// });
							if (this.ErpUserType=='HF') {
								uni.switchTab({
									url: '/pages/tabbar/home/index'
								});
							}else if (this.ErpUserType=='FP') {
								uni.switchTab({
									url: '/pages/tabbar/homeFP/index'
								});
							}
						}else{
							console.log('res')
							uni.showToast({
								title: res.data.message,
								type: 'default',
								icon:false
							})
						}
					},
					fail: (res) => {
						uni.hideLoading();
						uni.showToast({
							title: res.errMsg,
							type: 'default',
							icon:false
						})
					}
				});
			},
		}
	}
</script>

<style scoped>
	.box{
		margin:60rpx 40rpx 20rpx 40rpx;
	}
	.box-title{
		width: 206rpx;
		height: 60rpx;
		font-size: 42rpx;
		font-family: Source Han Sans SC;
		font-weight: 500;
		color: #333333;
		line-height: 60rpx;		
	}
	.box-title-center{
		height: 60rpx;
		font-size: 42rpx;
		font-family: Source Han Sans SC;
		font-weight: 500;
		color: #333333;
		line-height: 60rpx;
	}
	.textbox{
		width: 80%;
		margin: 40rpx auto;
	}
	.box-submit{
		margin-top: 80rpx;
	}
</style>
